#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; ++i)
using namespace std;
typedef long long ll;
const int N = 60;
ll a[N], b[N];
int n;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    cin >> n;
    ll res = 0;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    int amin = *min_element(a, a + n), bmin = *min_element(b, b + n);
    rep(i, 0, n) { res += max(a[i] - amin, b[i] - bmin); }
    cout << res << endl;
  }
}
